package li_xiang;

/**
 * @DESCRIPER:
 * @AUTHOR:lixiang
 * @PHONE:15226392261
 * @EMIAL:1214336214@qq.COM
 * @DATE: 2021-01-23 17:04
 * @PARAMDESCRIPER:
 * @OUTPARAMDESCRIPER:
 */
public class LI_XIANG_23_Q2 {

    static class ArrayQueue{
        // 定义一个数组
        private Object[] arr;
        // 定义数组的值
        private int date;
        // 队尾
        private int rear;
        // 队头
        private int front;
        // 队列的最大长度
        private int maxsize = 20;

        // 初始化数组
        public ArrayQueue(){
            arr = new Object[maxsize];
        }

        // 判断队列是否为满
        public Boolean isFull(){
            return rear == maxsize - 1;
        }

        // 判断队列是否为空
        public Boolean isEmpty(){
            return rear == front;
        }

        // 添加
        public void insert(int n){
            if (isFull()){
                System.out.println("队列已满0.0");
            }
            arr[rear] = n;
            rear++; // 队尾后移

        }

        // 删除---只能删除队列头
        public void delete(){
            if (isEmpty()){
                System.out.println("队列为空0.0");
            }
            arr[front] = null;
            front++;
            System.out.println("arr[front]" + arr[front]);
        }

        //
        public void showQueue(){
            if (isEmpty()){
                System.out.println("队列为空0.0");
            }
            for (int i = 0; i < arr.length ; i++){
                System.out.println("a[" + i + "]" + "=" + arr[i]);
            }
        }


    }

    public static void main(String[] args) {
        ArrayQueue arrayQueue = new ArrayQueue();
        for (int i = 0; i <= 19;i++){
            //
            arrayQueue.insert(i);
        }
//        arrayQueue.delete();
        arrayQueue.showQueue();
    }

}

